<template>
  <div>
    <zeda-dialog
      v-model="visible"
      width="50%"
      title="详情"
      :before-close="handleClose"
    >
      <Title slot="green">
        <desc-base-info
          :data="info"
          :colnum-info="colnumInfo"
          align="right"
          :no-line-height="true"
          label-width="120px"
          class="base-info"
        ></desc-base-info>
      </Title>
    </zeda-dialog>
  </div>
</template>
  <script>
import FormButton from "@/components/FormButton";
export default {
  components: {
    FormButton,
  },
  props: {
    visible: { type: Boolean, default: false },
    id: { type: [String, Number], default: "" },
    rowsData: { type: Object, default: {} },
  },
  data() {
    return {
      info: {},
      show: false,
    };
  },
  computed: {
    colnumInfo({ info }) {
      return [
        { label: "目标名称", prop: "repo", colNum: 2 },
        { label: "生成时间", prop: "time", colNum: 2 },
        { label: "分支", prop: "branch", colNum: 2 },
        { label: "生成主机", prop: "host", colNum: 2 },
        { label: "最近提交次数", prop: "commitCount", colNum: 2 },
        { label: "最近提交的标签名称", prop: "tagName", colNum: 2 },
        { label: "提交ID", prop: "id", colNum: 2 },
        { label: "提交ID缩写", prop: "abbrev", colNum: 2 },
        { label: "提交信息描述", prop: "msgFull", colNum: 2 },
        { label: "提交信息简要描述", prop: "msgShort", colNum: 2 },
        { label: "提交ID描述", prop: "idDescribe", colNum: 2 },
        { label: "提交ID简要描述", prop: "idDescribeShort", colNum: 2 },
        { label: "最后提交时间", prop: "commitTime", colNum: 2 },
        { label: "不纯净", prop: "dirty", colNum: 2 },
        { label: "当前版本标签", prop: "version", colNum: 2 },
      ];
    },
  },
  watch: {
    visible(value) {
      if (value) {
        this.getInfo();
      }
    },
  },
  methods: {
    getInfo() {
      this.info.repo = this.rowsData["repo"];
      this.info.time = this.rowsData["git.build.time"];
      this.info.branch = this.rowsData["git.branch"];
      this.info.host = this.rowsData["git.build.host"];
      this.info.version = this.rowsData["git.build.version"];
      this.info.commitCount = this.rowsData["git.total.commit.count"];
      this.info.tagName = this.rowsData["git.closest.tag.name"];

      this.info.id = this.rowsData["git.commit.id"];
      this.info.abbrev = this.rowsData["git.commit.id.abbrev"];
      this.info.msgFull = this.rowsData["git.commit.message.full"];
      this.info.msgShort = this.rowsData["git.commit.message.short"];

      this.info.idDescribe = this.rowsData["git.commit.id.describe"];
      this.info.idDescribeShort = this.rowsData["git.commit.id.describe-short"];
      this.info.commitTime = this.rowsData["git.commit.time"];

      this.info.dirty = this.rowsData["git.dirty"];
      this.info.commitTime = this.rowsData["git.commit.time"];
    },
    handleClose(status) {
      this.$emit("close", typeof status === "boolean" ? status : false);
    },
  },
};
</script>
  